/*
	Description: Map county FIPS codes into consistent county codes.
	
	Author: Brendan Price
	Updated: January 18, 2018
	
	Note: This script ignores county changes in Alaska and Hawaii.
	
	Sources:
	- David Dorn's memo "FIPS County Code Changes"
	- Census Tiger County Changes
	- Census Bureau: https://www.census.gov/geo/reference/county-changes.html
*/

* Must be in memory
confirm variable cty_fips

* Combine Yuma and La Paz Counties, AZ
replace cty_fips = 04027 if cty_fips == 04012

* Combine Broomfield and Boulder Counties, CO
replace cty_fips = 08013 if cty_fips == 08014

* Recode Miami-Dade County, FL
replace cty_fips = 12025 if cty_fips == 12086

* Combine Columbus, GA with Muscogee County, GA
replace cty_fips = 13215 if cty_fips == 13510

* Recode Ste. Genevieve, MO
replace cty_fips = 29186 if cty_fips == 29193

* Combine two Park County, MT codes
replace cty_fips = 30067 if cty_fips == 30901

* Combine Yellowstone National Park with Yellowstone County, MT
replace cty_fips = 30111 if cty_fips == 30113

* Combine Valencia and Cibola Counties, NM
replace cty_fips = 35061 if cty_fips == 35006

* Combine the five boroughs of NYC into a single county (i.e. Manhattan)
replace cty_fips = 36061 if cty_fips == 36005 | cty_fips == 36047 | cty_fips == 36081 | cty_fips == 36085

* Combine Washabaugh, SD with Jackson, SD
replace cty_fips = 46071 if cty_fips == 46131

* Combine Nansemond County, VA with Suffolk (independent city), VA
replace cty_fips = 51800 if cty_fips == 51123

* Combine Kalawao County, HI with Maui County, HI
replace cty_fips = 15009 if cty_fips == 15005

* Combine Shannon County, SD with Oglala Lakota County, South Dakota (name change)
replace cty_fips = 46102 if cty_fips == 46113

* Combine Shawano, WI with Menominee, WI
replace cty_fips = 55901 if cty_fips == 55078
replace cty_fips = 55901 if cty_fips == 55115

* Absorb independent Virginia cities into the counties that surround them
replace cty_fips = 51019 if cty_fips == 51515
replace cty_fips = 51191 if cty_fips == 51520
replace cty_fips = 51163 if cty_fips == 51530
replace cty_fips = 51003 if cty_fips == 51540
replace cty_fips = 51005 if cty_fips == 51560
replace cty_fips = 51041 if cty_fips == 51570
replace cty_fips = 51005 if cty_fips == 51580
replace cty_fips = 51143 if cty_fips == 51590
replace cty_fips = 51081 if cty_fips == 51595
replace cty_fips = 51059 if cty_fips == 51600
replace cty_fips = 51059 if cty_fips == 51610
replace cty_fips = 51175 if cty_fips == 51620
replace cty_fips = 51177 if cty_fips == 51630
replace cty_fips = 51077 if cty_fips == 51640
replace cty_fips = 51165 if cty_fips == 51660
replace cty_fips = 51149 if cty_fips == 51670
replace cty_fips = 51163 if cty_fips == 51678
replace cty_fips = 51031 if cty_fips == 51680
replace cty_fips = 51153 if cty_fips == 51683
replace cty_fips = 51153 if cty_fips == 51685
replace cty_fips = 51089 if cty_fips == 51690
replace cty_fips = 51195 if cty_fips == 51720
replace cty_fips = 51053 if cty_fips == 51730
replace cty_fips = 51199 if cty_fips == 51735
replace cty_fips = 51710 if cty_fips == 51740
replace cty_fips = 51121 if cty_fips == 51750
replace cty_fips = 51087 if cty_fips == 51760
replace cty_fips = 51161 if cty_fips == 51770
replace cty_fips = 51161 if cty_fips == 51775
replace cty_fips = 51083 if cty_fips == 51780
replace cty_fips = 51015 if cty_fips == 51790
replace cty_fips = 51015 if cty_fips == 51820
replace cty_fips = 51095 if cty_fips == 51830
replace cty_fips = 51069 if cty_fips == 51840
